home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / ppreview / previewt.bas < prev    next >
Encoding:
BASIC Source File  |  1998-01-16  |  6.1 KB  |  180 lines

  1. Attribute VB_Name = "PreviewTestModule"
  2.  
  3. Option Explicit
  4. Private Sub Test1()
  5. Dim longstrings As String
  6. longstrings = "Now is the time for all good men to come to the aid of their country.  The quick brown fox jumped over the lazy dog.  The rain in spain falls mainly on the plain.  The quick brown fox jumped over the lazy dog."
  7. PreviewPrint1.PaperSize = 1
  8. PreviewPrint1.Orientation = 2
  9.  
  10. PreviewPrint1.FontName = "Arial"
  11. PreviewPrint1.FontSize = 12
  12. PreviewPrint1.FontStrikethru = True
  13. PreviewPrint1.CurrentX = 1000
  14. PreviewPrint1.CurrentY = 1000
  15. PreviewPrint1.PreviewText longstrings, False
  16. PreviewPrint1.FontStrikethru = False
  17. PreviewPrint1.CurrentX = 300
  18. PreviewPrint1.CurrentY = 3000
  19. PreviewPrint1.FontSize = 16
  20. PreviewPrint1.FontUnderline = True
  21. PreviewPrint1.FontName = "Times New Roman"
  22. PreviewPrint1.FontBold = True
  23. PreviewPrint1.FontItalic = True
  24. PreviewPrint1.PreviewText "Some more text to look at", False
  25. PreviewPrint1.PreviewCircle 2000, 2000, 1500
  26. PreviewPrint1.PreviewLine 1000, 2000, 3000, 2200, QBColor(7), "BF"
  27. PreviewPrint1.PreviewPSet 1000, 1500, 3, QBColor(4)
  28. PreviewPrint1.NewPage
  29. PreviewPrint1.FontName = "Arial"
  30. PreviewPrint1.FontSize = 12
  31. PreviewPrint1.FontStrikethru = True
  32. PreviewPrint1.CurrentX = 1000
  33. PreviewPrint1.CurrentY = 1000
  34. PreviewPrint1.PreviewText "This is page 2 of the test", False
  35. PreviewPrint1.FontStrikethru = False
  36. PreviewPrint1.CurrentX = 300
  37. PreviewPrint1.CurrentY = 3000
  38. PreviewPrint1.FontSize = 16
  39. PreviewPrint1.FontUnderline = True
  40. PreviewPrint1.FontName = "Times New Roman"
  41. PreviewPrint1.FontBold = True
  42. PreviewPrint1.FontItalic = True
  43. PreviewPrint1.PreviewText "Some more text to look at on page 2", False
  44. PreviewPrint1.PreviewCircle 2000, 2000, 1500, QBColor(4)
  45. PreviewPrint1.PreviewLine 1000, 2000, 3000, 2400, QBColor(4), "B"
  46. PreviewPrint1.PreviewPSet 1000, 1500, 3, QBColor(4)
  47.  
  48. PreviewPrint1.FontUnderline = False
  49. End Sub
  50. Private Sub Realtest(TitlePage As String)
  51. Dim textstring As String, textlength As Single
  52. Dim i As Integer, j As Integer, cx As Single, cy As Single
  53. Dim entry As String
  54.  
  55. Const TwipsAre = 1440
  56. PreviewPrint1.PaperSize = 1
  57. PreviewPrint1.Orientation = 1
  58. PreviewPrint1.FontName = "Times New Roman"
  59. PreviewPrint1.FontSize = 14
  60. PreviewPrint1.ForeColor = QBColor(4)
  61. PreviewPrint1.CurrentY = 1 * TwipsAre
  62.  
  63. PreviewPrint1.FontBold = True
  64. textstring = "This is the title of the table"
  65. textlength = PreviewPrint1.PreviewTextWidth(textstring)
  66. PreviewPrint1.CurrentX = 4 * TwipsAre - textlength / 2
  67. PreviewPrint1.PreviewText textstring, True
  68. '
  69. textlength = PreviewPrint1.PreviewTextWidth(TitlePage)
  70. PreviewPrint1.CurrentX = 4 * TwipsAre - textlength / 2
  71. PreviewPrint1.PreviewText TitlePage, True
  72.  
  73. ' now, make several lines of columns of width 1"
  74.  
  75. PreviewPrint1.ForeColor = QBColor(0)
  76. PreviewPrint1.FontSize = 8
  77. PreviewPrint1.FontBold = False
  78. PreviewPrint1.FontItalic = True
  79.  
  80. cy = PreviewPrint1.CurrentY
  81. Dim ff As New StdFont
  82. For i = 0 To 25 ' i = rows
  83. '    ff.Name = Printer.Fonts(i)
  84.     'PreviewPrint1.FontName = Printer.Fonts(i + 4)
  85.     'Debug.Print i, PreviewPrint1.FontName
  86.     
  87.     textstring = "Row" & Str$(i)
  88.     cy = cy + PreviewPrint1.PreviewTextHeight(textstring)
  89.     PreviewPrint1.CurrentY = cy
  90.     For j = 0 To 6
  91.        entry = textstring & "Col" & Str$(j)
  92.        PreviewPrint1.CurrentX = (1.5 + j) * TwipsAre - PreviewPrint1.PreviewTextWidth(entry)
  93.        PreviewPrint1.PreviewText entry, False
  94.     Next j
  95. Next i
  96. cy = cy + 0.35 * TwipsAre
  97. cx = 0.5 * TwipsAre
  98.  
  99. PreviewPrint1.PreviewLine cx, cy, 8 * TwipsAre, cy, , "B"
  100. textstring = "This is a line of text below the line"
  101. cy = cy + 1.5 * PreviewPrint1.PreviewTextHeight(textstring)
  102. cx = 0.5 * TwipsAre
  103. PreviewPrint1.CurrentX = cx
  104. PreviewPrint1.CurrentY = cy
  105. PreviewPrint1.PreviewText textstring, False
  106.  
  107. Set ff = Nothing
  108.  
  109. End Sub
  110.  
  111.  
  112.  
  113.  
  114. Public Sub DrivePreview()
  115.  
  116. Test1
  117. PreviewPrint1.NewPage
  118.  Realtest "Page 1"
  119.   PreviewPrint1.NewPage
  120.   Realtest "Page 2"
  121.   PreviewPrint1.NewPage
  122.   Realtest "Page 3"
  123.   PreviewPrint1.NewPage
  124.   Test1
  125.   PreviewPrint1.NewPage
  126.  
  127. PreviewPrint1.EndDocument
  128.  
  129. End Sub
  130.  
  131. Public Sub LastTest()
  132.  Dim longstrings As String
  133.  longstrings = "Now is the time for all good men to come to the aid of their country.  The quick brown fox jumped over the lazy dog.  The rain in spain falls mainly on the plain.  The quick brown fox jumped over the lazy dog."
  134.  PreviewPrint1.PaperSize = 1
  135.  PreviewPrint1.Orientation = 2
  136.  PreviewPrint1.ForeColor = QBColor(4)
  137.   PreviewPrint1.FontName = "Arial"
  138.   PreviewPrint1.FontSize = 12
  139.   PreviewPrint1.FontStrikethru = True
  140.  PreviewPrint1.CurrentX = 1000
  141.  PreviewPrint1.CurrentY = 1000
  142.  PreviewPrint1.PreviewText longstrings, False
  143.   PreviewPrint1.FontStrikethru = False
  144.   PreviewPrint1.FontName = "Playbill"
  145.  PreviewPrint1.CurrentX = 1000
  146.  PreviewPrint1.CurrentY = 1400
  147.  PreviewPrint1.PreviewText longstrings, False
  148.  PreviewPrint1.CurrentX = 300
  149.  PreviewPrint1.CurrentY = 3000
  150.   PreviewPrint1.FontSize = 16
  151.   PreviewPrint1.FontUnderline = True
  152.   PreviewPrint1.FontName = "Times New Roman"
  153.   PreviewPrint1.FontBold = True
  154.   PreviewPrint1.FontItalic = True
  155.  PreviewPrint1.PreviewText "Some more text to look at", False
  156.  PreviewPrint1.PreviewCircle 2000, 2000, 1500, QBColor(4)
  157.  PreviewPrint1.PreviewLine 1000, 2000, 3000, 2200, QBColor(6), "BF"
  158.  PreviewPrint1.PreviewPSet 1000, 1500, 3, QBColor(4)
  159.  PreviewPrint1.NewPage
  160.   PreviewPrint1.FontName = "Arial"
  161.   PreviewPrint1.FontSize = 12
  162.   PreviewPrint1.FontStrikethru = True
  163.  PreviewPrint1.CurrentX = 1000
  164.  PreviewPrint1.CurrentY = 1000
  165.  PreviewPrint1.PreviewText "This is page 2 of the test", False
  166.   PreviewPrint1.FontStrikethru = False
  167.  PreviewPrint1.CurrentX = 300
  168.  PreviewPrint1.CurrentY = 3000
  169.   PreviewPrint1.FontSize = 16
  170.   PreviewPrint1.FontUnderline = True
  171.   PreviewPrint1.FontName = "Times New Roman"
  172.   PreviewPrint1.FontBold = True
  173.   PreviewPrint1.FontItalic = True
  174.  PreviewPrint1.PreviewText "Some more text to look at on page 2", False
  175.  PreviewPrint1.PreviewCircle 2000, 2000, 1500
  176.  PreviewPrint1.PreviewLine 1000, 2000, 3000, 2000, 0
  177.  PreviewPrint1.PreviewPSet 1000, 1500, 3, QBColor(4)
  178.  
  179. End Sub
  180.